<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>rem 布局方案</title>
        <style>
            * {
                margin: 0;
                padding: 0;
            }
            img {
                width: 100%;
            }
            html {
                font-size: 16px;
            }
            .tabbar-layout {
                position: fixed;
                bottom: 0;
                left: 0;
                box-shadow: 0 -4px 4px rgba(0, 0, 0, 0.15);
                width: 46.875rem /* 750/16 */;
                height: 6rem /* 96/16 */;
            }
        </style>
    </head>
    <body>
        <div class="tabbar-layout">
            <img
                src="https://markdown-1253389072.cos.ap-nanjing.myqcloud.com/202112101446793.png"
                alt="标签栏"
            />
        </div>
    </body>
    <script>
        function setHtmlFontSize() {
            // 获取用户的手机尺寸
            const clientWidth =
                document.documentElement.clientWidth ||
                window.innerWidth ||
                document.documentElement.getBoundingClientRect().width;
            // 计算html标签对应的字体大小
            const htmlFontSize = clientWidth / 46.875 + "px";
            // 通过js来动态修改html标签的字体大小
            document.documentElement.style.fontSize = htmlFontSize;
        }
        // 监控尺寸变化, 每次尺寸变换, 调用setHtmlFontSize函数
        window.onresize = setHtmlFontSize;
    </script>
</html>
